/*
This software is distributed under the Simplified BSD License:

Copyright (c) 2008, Chris Venter <chris.venter@gmail.com>
All rights reserved.

Redistribution and use in source and binary forms, with or without modification, 
are permitted provided that the following conditions are met:

    * Redistributions of source code must retain the above copyright notice, 
    	this list of conditions and the following disclaimer.
    * Redistributions in binary form must reproduce the above copyright notice, 
    	this list of conditions and the following disclaimer in the documentation 
    	and/or other materials provided with the distribution.

THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY 
EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES 
OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT 
SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, 
INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED 
TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR 
BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN 
CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN 
ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH 
DAMAGE.
*/
#ifndef GENERIK_DBSPI_H
#define GENERIK_DBSPI_H

/** \file dbspi.h
This file specifies a generik interface to a server-side SPI database api implementation.
*/

#include "database.h"
#include "tracing.h"

/** \def DBSPI_DEFINE_FUNC(FUNC)
	Simplifies the decleration of a function FUNC.
*/

/** \def DBSPI_END_FUNC
	Simplifies the closing of a function - required!
*/

/** \def DBSPI_GET_HANDLE
	Creates a handle to the generik::dbspi which describes the database.
*/

/** \def DBSPI_HANDLE
	Returns the handle created by DBSPI_GET_HANDLE.
	\note DBSPI_GET_HANDLE should be in a body once before any calls to DBSPI_HANDLE.
*/

/** \def DBSPI_GETARG_INT(INDEX)
	Returns the argument at the specified INDEX.
*/

/** \def DBSPI_RETURN_INT(VALUE)
	Tells the backend to return the specified VALUE as an integer.
*/

/** \def DBSPI_TRACER
	Creates a log entry, as "[<FUNCTION>] [running]".
	Useful for debugging purposes.
*/

/** \def DBSPI_LOG(MESSAGE)
	Echoes MESSAGE as a log entry.
	MESSAGE can be in "c++ stream", ie. DBSPI_LOG("hello "<<world);
*/

/** \def DBSPI_ERROR(MESSAGE)
	Echoes MESSAGE as an error entry.
	MESSAGE can be in "c++ stream", ie. DBSPI_LOG("oh "<<no<<"!!!");
*/


namespace generik
{

	/** The dbspi interface.
	This interface provides querying for server-side code.
	Thus it inherits the database_query_handling interface.
	
	Examples can be found in dbsi/sqlite.h and dbspi/postgres.h
	*/
	struct dbspi
	: database_query_handling
	{
		dbspi()
		{
			GENERIK_TRACER;
		}
		
		virtual ~dbspi()
		{
			GENERIK_TRACER;
		}
	};
	
}

#endif

